package com.hkts.naturalgas.performance.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hkts.naturalgas.performance.entity.HkFormRelationShip;
import com.hkts.naturalgas.performance.mapper.HkFormRelationShipMapper;
import com.hkts.naturalgas.performance.service.IHkFormRelationShipService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yck
 * @since 2020-12-22
 */
@Service
@Transactional
public class HkFormRelationShipServiceImpl extends ServiceImpl<HkFormRelationShipMapper, HkFormRelationShip> implements IHkFormRelationShipService {


@Autowired
private HkFormRelationShipMapper hkFormRelationShipMapper;

@Override
public IPage<HkFormRelationShip> selectPage(Page<HkFormRelationShip> page, HkFormRelationShip hkFormRelationShip){
        QueryWrapper<HkFormRelationShip> query = Wrappers.query();
        QueryWrapper<HkFormRelationShip> entityWrapper = getEntityWrapper(query, hkFormRelationShip);
        return hkFormRelationShipMapper.selectPage(page, entityWrapper);
        }




@Override
public List<HkFormRelationShip> selectList(HkFormRelationShip hkFormRelationShip){
        QueryWrapper<HkFormRelationShip> query = Wrappers.query();
        QueryWrapper<HkFormRelationShip> entityWrapper = getEntityWrapper(query, hkFormRelationShip);
        return hkFormRelationShipMapper.selectList(entityWrapper);
        }

/**
 *  公共查询条件
 * @param entityWrapper
 * @return
 */
public QueryWrapper<HkFormRelationShip> getEntityWrapper(QueryWrapper<HkFormRelationShip> entityWrapper,HkFormRelationShip hkFormRelationShip){
        //条件拼接
                if(StringUtils.isNotBlank(hkFormRelationShip.getCreateBy())){
                entityWrapper.like(HkFormRelationShip.CREATE_BY,hkFormRelationShip.getCreateBy());
                }
              /*  if(StringUtils.isNotBlank(hkFormRelationShip.getCreateTime())){
                entityWrapper.like(HkFormRelationShip.CREATE_TIME,hkFormRelationShip.getCreateTime());
                }
                if(StringUtils.isNotBlank(hkFormRelationShip.getDelFlag())){
                entityWrapper.like(HkFormRelationShip.DEL_FLAG,hkFormRelationShip.getDelFlag());
                }*/
                if(StringUtils.isNotBlank(hkFormRelationShip.getUpdateBy())){
                entityWrapper.like(HkFormRelationShip.UPDATE_BY,hkFormRelationShip.getUpdateBy());
                }
              /*  if(StringUtils.isNotBlank(hkFormRelationShip.getUpdateTime())){
                entityWrapper.like(HkFormRelationShip.UPDATE_TIME,hkFormRelationShip.getUpdateTime());
                }*/
                if(StringUtils.isNotBlank(hkFormRelationShip.getFormId())){
                entityWrapper.like(HkFormRelationShip.FORM_ID,hkFormRelationShip.getFormId());
                }
                if(StringUtils.isNotBlank(hkFormRelationShip.getItemId())){
                entityWrapper.like(HkFormRelationShip.ITEM_ID,hkFormRelationShip.getItemId());
                }
               /* if(StringUtils.isNotBlank(hkFormRelationShip.getSortNumber())){
                entityWrapper.like(HkFormRelationShip.SORT_NUMBER,hkFormRelationShip.getSortNumber());
                }*/
        return entityWrapper;
        }
        }
